

#ifndef __CORTISOL_GLPROGRAM_H
#define __CORTISOL_GLPROGRAM_H

#include "GLVertexShader.h"
#include "GLFragmentShader.h"

class GLProgram
	:	public virtual Object {

	GLuint program;

	const	GLVertexShader		vertexShader;
	const	GLFragmentShader	fragmentShader;

public:

	GLProgram(	const	GLVertexShader		vertexShader,
				const	GLFragmentShader	fragmentShader	)
				:	vertexShader	( vertexShader		),
					fragmentShader	( fragmentShader	) {

		Initialise();
	}
				

	virtual ~GLProgram() throw() {

		Dispose();
	}


private:

	void Initialise(void) {

		program = glCreateProgram();
		glAttachShader( program, vertexShader->GetShader() );
		glAttachShader( program, fragmentShader->GetShader() );
		glLinkProgram( program );
	}

	void Dispose(void) {

		glDetachShader( program, vertexShader->GetShader() );
		glDetachShader( program, fragmentShader->GetShader() );
		glDeleteProgram( program );
	}
}

#endif /*** __CORTISOL_GLPROGRAM_H ***/

